package com.uniquesoft.excelwriter;



import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import com.uniquesoft.excelwriter.Sheet2.FamilyMember;

public class CreateExcelFromTemplate {

	public static void main(String[] args) throws Exception {
		
		//第一个sheet的构建
		
		WriteExcelUtils writeExcelUtils = new WriteExcelUtils();
		//第五步： 填充数据到sheet里面
		Sheet1 sheet1 = new Sheet1();
		Date birthDay = WriteExcelUtils.sdf.parse("2017.1") ;
		sheet1.setBirthday(birthDay);
		System.out.println("birthDay="+sheet1.getBirthday());

		Sheet2 sheet2 = new Sheet2();
		ArrayList<FamilyMember> familyMembers =  new ArrayList<FamilyMember>();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy.mm");
		Date date1 = sdf.parse("1990.10");
		Date date2 = sdf.parse("1990.11");
		
		familyMembers.add(new FamilyMember("丈夫", "张三", date1, "群众", "IBM咨询经理"));
		familyMembers.add(new FamilyMember("女儿", "李四", date2, "党员", "工程师"));
		sheet2.setFamilyMembers(familyMembers);
		sheet2.setRewards("2005年被评为上海市商业投资（集团）有限公司先进个人");
		sheet2.setAnnualAppraisal("奖金三万");
		sheet2.setRemovalReason("工作需要");
		sheet2.setApplicant("王五");
        
		AppravalFormWB afwb = new AppravalFormWB();
		BaseSheet[] bss = new BaseSheet[2];
		bss[0] = sheet1;
		bss[1] = sheet2;
		afwb.setSheets(bss);
		writeExcelUtils.writeExcel(afwb, "/sandbox/Workspace/excelhandler/src/excel1.xls", "/sandbox/newExcelFileFromTemplate.xls");
		System.out.println("构建表格完成");
		
	}
}
